<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<c:import url="/WEB-INF/jsp/head.jsp"/>
</head>
<body>

	<c:import url="/WEB-INF/jsp/cabecalho.jsp"/>
	
	<h3 align="center">Matricular Alunos</h3>
	<h3 align="center">${formacao.nome}</h3>
	
	<form method="post" action="<c:url value="/matriculaFormacao/salvar"/>">
	
		<c:if test="${not empty errors}">
			<div id="erros" style="color:red" class="erros">
				Foram encontrados erros no cadastro:<br/>
				<ul>
				<c:forEach var="error" items="${errors}">
				    <li>${error.message}</li>
				</c:forEach>
				</ul>
			</div>
		</c:if>
		
		<table align="center" width="200px" border="0">
			<c:forEach items="${formacao.formacaoAlunos}" var="formacaoAluno" >
			<tr>
				<td width="90%" align="center" ><h5>${formacaoAluno.aluno.nome}</h5></td>
				<td width="10%" align="left"><input type="checkbox" name="alunos[${formacaoAluno.aluno.id}].id" value="${formacaoAluno.aluno.id}" checked="checked" /></td>
			</tr>
			</c:forEach>
			<c:forEach items="${alunos}" var="aluno" >
			<tr>
				<td width="90%" align="center" ><h5>${aluno.nome}</h5></td>
				<td width="10%" align="left"><input type="checkbox" name="alunos[${aluno.id}].id" value="${aluno.id}" /></td>
			</tr>
			</c:forEach>
		</table>
		
		<br /><br />
		
		<div align="center">
			<input type="submit" name="btnEnviar" id="btnEnviar" value="Enviar" />
			<input type="reset" name="btnLimpar" id="btnLimpar" value="Limpar" />
		</div>
	</form>
	
	<div align="center">
		<br /><br /><br />
		<a href="<c:url value="/matriculaFormacao"/>">Voltar</a>
	</div>
	
	<c:import url="/WEB-INF/jsp/rodape.jsp"/>
<script type="text/javascript">
	function semMatricula(campo){
		if(campo.value == "Matrícula"){
			campo.value = "";
		}
	}
</script>
</body>
</html>